package bug.persistent;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import javax.persistence.*;
import java.util.List;

/**
 * User: ion
 * Date: Aug 30, 2008 - 3:17:51 PM
 */

@Entity
public class Project extends PO {
    private String name;
    private List<UserProject> userProjects;

    @Column(name = "Name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @OneToMany(mappedBy = "project", fetch = FetchType.LAZY)
    @Fetch(value = FetchMode.SUBSELECT)
    public List<UserProject> getUserProjects() {
        return userProjects;
    }

    public void setUserProjects(List<UserProject> userProjects) {
        this.userProjects = userProjects;
    }

    public void addUserProject(UserProject userProject) {
        this.getUserProjects().add(userProject);
    }
}